package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsAccountTrace;
import com.qf.service.DtsAccountTraceService;
import com.qf.util.ResponseUtil;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author YDW
 * projectName:shop-manage
 * time:2022/5/24 9:53
 * description:
 */
@RestController
@RequestMapping("/admin/brokerage")
public class AdminBrokerageController {

    @Autowired
    DtsAccountTraceService accountTraceService;


    @RequiresPermissions("admin:brokerage:list")
    @RequiresPermissionsDesc(menu = { "用户管理", "佣金管理" }, button = "查询")
    @GetMapping("/list")
    public Object list(
            @RequestParam(name = "page",required = false,defaultValue = "1") Integer page,
            @RequestParam(name = "limit",required = false,defaultValue = "10") Integer limit,
            String mobile, String username,  String sort, String order
            ){
        IPage<DtsAccountTrace> ipage=accountTraceService.queryPage(page,limit,sort,order,mobile,username);
        Map<String,Object> data=new HashMap<>();
        data.put("total",ipage.getTotal());
        data.put("traceList",ipage.getRecords());
        return ResponseUtil.ok(data);
    }

    @RequiresPermissions("admin:brokerage:approve")
    @RequiresPermissionsDesc(menu = { "用户管理", "佣金管理" }, button = "审批")
    @PostMapping("/approve")
    public Object approve(@RequestBody DtsAccountTrace accountTrace){

        return accountTraceService.approve(accountTrace);
    }
}
